package ae.pcfc.cldos.online.web.controller.file;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import ae.pcfc.cldos.online.common.delegate.FileHandlerDelegate;
import ae.pcfc.cldos.online.common.vo.FileVO;
import ae.pcfc.cldos.online.web.ViewPath;

@Controller
public class FileTransferedController {

	@Autowired
	@Qualifier("fileHandlerDelegate")
	private FileHandlerDelegate fileHandlerDelegate;
	
	@RequestMapping(ViewPath.__FILE_TRANSFERED+"/{fileId}")
	public @ResponseBody String handleRequest(@PathVariable String fileId, HttpServletResponse response){
		
		FileVO fileVO = new FileVO();
		Long lFileId = null;
		try{
			lFileId = Long.parseLong(fileId);
			fileVO.setId(lFileId);
		} catch (NumberFormatException e){}
		
		String resp = "";
		if(lFileId!=null){
			fileHandlerDelegate.updateTransferFlag(fileVO);
			resp="checked";
		} else {
			resp="bad file id";
		}
		
		return resp;
	}
	
}
